# coding=utf-8
#! /usr/bin/python

"""
__author__='wudi'
@File:wechat_instance.py
@Time:2017/5/25 11:10
"""
#解决编码不一致问题
import sys

reload(sys)
sys.setdefaultencoding("utf-8")

import itchat

#这里参数输入微信名称的全拼
def get_userid(quanpin):
    account=itchat.get_friends()
    userid = ''
    for i in account:
        # print i['PYQuanPin']
        if i['PYQuanPin']==quanpin:
            userid = i['UserName']
            break
    return userid

def sendmsg(userid):
    itchat.send(u'截止昨天的销售进度日报如下图：', toUserName=userid)
    itchat.send(u'@img@%s' %'templateImage0.png', toUserName=userid)

if __name__=="__main__":
    itchat.auto_login(hotReload=True)
    userid = get_userid('Edricdi')
    sendmsg(userid)

